<script>
//自定义指令
const focus = {
  mounted(el) {
    return el.focus()
  },
}
export default {
  //局部注册，也可以全局注册
  directives: {
    focus,
  },
}
</script>

<template>
  <input type="text" v-focus />
</template>
